package com.googlecode.imule.neilisageniuswhoshouldgetanA;

import java.awt.image.BufferedImage;
import java.io.IOException;

import javax.swing.ImageIcon;

import org.jdesktop.swingx.JXLabel;
import org.jdesktop.swingx.graphics.GraphicsUtilities;

/* TODO: Document & add mouse events
 * Properly implement as a button, hiding most of the stuff
 * perhaps add a zoom and mouseOver using ScreenTransition
 */
public class iMenuButton extends JXLabel implements Comparable<iMenuButton>{

	private BufferedImage image;
	private String name;
	
	public iMenuButton(String url, String name){
		this.name = name;
		loadImage(url);
		
		setIcon(new ImageIcon(image));
	}
	
	
	
	public BufferedImage getImage() {
		return image;
	}



	public void setImage(BufferedImage image) {
		this.image = image;
	}



	public String getName() {
		return name;
	}



	public void setName(String name) {
		this.name = name;
	}



	/**
	 * Load an image from file.
	 * 
	 * @param url, the location of the file
	 */
	private void loadImage(String url){
		try {
			image = GraphicsUtilities.loadCompatibleImage(getClass().getResource(url));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public int compareTo(iMenuButton arg0) {
		return getName().compareTo(arg0.getName());
	}
}
